function residual = dynamic_resid(T, y, x, params, steady_state, it_, T_flag)
% function residual = dynamic_resid(T, y, x, params, steady_state, it_, T_flag)
%
% File created by Dynare Preprocessor from .mod file
%
% Inputs:
%   T             [#temp variables by 1]     double   vector of temporary terms to be filled by function
%   y             [#dynamic variables by 1]  double   vector of endogenous variables in the order stored
%                                                     in M_.lead_lag_incidence; see the Manual
%   x             [nperiods by M_.exo_nbr]   double   matrix of exogenous variables (in declaration order)
%                                                     for all simulation periods
%   steady_state  [M_.endo_nbr by 1]         double   vector of steady state values
%   params        [M_.param_nbr by 1]        double   vector of parameter values in declaration order
%   it_           scalar                     double   time period for exogenous variables for which
%                                                     to evaluate the model
%   T_flag        boolean                    boolean  flag saying whether or not to calculate temporary terms
%
% Output:
%   residual
%

if T_flag
    T = M15ra.dynamic_resid_tt(T, y, x, params, steady_state, it_);
end
residual = zeros(10, 1);
    residual(1) = (T(1)*T(4)) - (params(2)*y(7)^params(7)+T(5)*T(6));
    residual(2) = (T(6)+T(9)*T(10)) - (T(12)*(1-params(3)+params(4)*T(10)));
    residual(3) = (y(12)) - (params(6)-params(8)*(y(3)-params(9)));
    residual(4) = (y(4)+y(6)) - (y(3));
    residual(5) = (y(3)) - (T(13)*exp(y(9))*T(14));
    residual(6) = (y(6)) - (y(5)-(1-params(3))*y(1));
    residual(7) = (y(8)) - (y(3)/y(7));
    residual(8) = (y(9)) - (params(5)*y(2)+x(it_, 1));
    residual(9) = (y(10)) - (T(14)*T(15)-params(3));
    residual(10) = (y(11)) - (T(13)*(1-params(4))*T(16));

end
